package com.xdcplus.web.controller.bd;



import com.xdcplus.exceptions.domain.ResponseVO;
import com.xdcplus.mom.controller.AbstractController;

import com.xdcplus.pager.vo.PageVO;
import com.xdcplus.web.common.pojo.dto.bd.BdWetWeightTargetDTO;
import com.xdcplus.web.common.pojo.dto.bd.BdWetWeightTargetFilterDTO;
import com.xdcplus.web.common.pojo.vo.bd.BdWetWeightTargetVO;
import com.xdcplus.web.service.bd.BdWetWeightTargetService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Validation;
import javax.validation.constraints.NotNull;


/**
 * 丝印湿重目标维护(BdWetWeightTarget)表服务控制层
 *
 * @author Zhecheng.Ren
 * @since 2024-10-22 15:10:15
 */
@Api(tags = "丝印湿重目标维护(BdWetWeightTarget)") 
@Slf4j
@Validated
@RestController
@AllArgsConstructor
@RequestMapping("bdWetWeightTarget")
public class BdWetWeightTargetController extends AbstractController {

    @Resource
    private BdWetWeightTargetService bdWetWeightTargetService;

    @ApiOperation("新增丝印湿重目标维护")
    @PostMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseVO<Void> saveBdWetWeightTarget(@RequestBody BdWetWeightTargetDTO bdWetWeightTargetDTO) {

        log.info("saveBdWetWeightTarget {}", bdWetWeightTargetDTO.toString());

        bdWetWeightTargetDTO.setCreatedUser(getAccount());
        bdWetWeightTargetService.saveBdWetWeightTarget(bdWetWeightTargetDTO);

        return ResponseVO.success();
    }

    @ApiOperation("修改丝印湿重目标维护")
    @PutMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseVO<Void> updateBdWetWeightTarget(@RequestBody BdWetWeightTargetDTO bdWetWeightTargetDTO) {

        log.info("updateBdWetWeightTarget {}", bdWetWeightTargetDTO.toString());

        bdWetWeightTargetDTO.setUpdatedUser(getAccount());
        bdWetWeightTargetService.updateBdWetWeightTarget(bdWetWeightTargetDTO);

        return ResponseVO.success();
    }

    @ApiOperation("删除丝印湿重目标维护")
    @DeleteMapping(value = "/{bdWetWeightTargetId}", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "bdWetWeightTargetId", dataTypeClass = Long.class, value = "丝印湿重目标维护ID", required = true),
    })
    public ResponseVO<Void> deleteBdWetWeightTargetLogical(@PathVariable("bdWetWeightTargetId")
                                         @NotNull(message = "丝印湿重目标维护ID不能为空") Long bdWetWeightTargetId) {

        log.info("deleteBdWetWeightTargetLogical {}", bdWetWeightTargetId);

        bdWetWeightTargetService.deleteBdWetWeightTargetLogical(bdWetWeightTargetId);

        return ResponseVO.success();
    }
    
    @ApiOperation("批量删除丝印湿重目标维护")
    @DeleteMapping(value = "/deleteByIds/{bdWetWeightTargetIds}", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "bdWetWeightTargetId", dataTypeClass = Long.class, value = "丝印湿重目标维护ID", required = true),
    })
    public ResponseVO<Void> deleteBdWetWeightTargetLogical(@PathVariable("bdWetWeightTargetIds")
                                         @NotNull(message = "丝印湿重目标维护ID不能为空") String bdWetWeightTargetIds) {

        log.info("deleteBdWetWeightTargetByIds {}", bdWetWeightTargetIds);

        bdWetWeightTargetService.deleteBdWetWeightTargetByIds(bdWetWeightTargetIds);

        return ResponseVO.success();
    }

    @ApiOperation("查询丝印湿重目标维护")
    @GetMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseVO<PageVO<BdWetWeightTargetVO>> findBdWetWeightTarget(BdWetWeightTargetFilterDTO bdWetWeightTargetFilterDTO) {

        log.info("findBdWetWeightTarget {}", bdWetWeightTargetFilterDTO);

        Validation.buildDefaultValidatorFactory().getValidator().validate(bdWetWeightTargetFilterDTO);

        return ResponseVO.success(bdWetWeightTargetService.queryBdWetWeightTarget(bdWetWeightTargetFilterDTO));
    }


}
